import React from "react";
import instance from "../../../utils/request";


export const _getAds = async () => {
  try {
    const res = await instance.get('ads/all-ads',{
      headers:{
        "Content-Type": "application/json",
      }
    })
    return res.data
  } catch (err) {
    console.log("error:",err);  
  }
}

export const _changePng = async (id,formData) => {
  try {    
    const res = await instance.put(`ads/ad/${id}`,formData,{
      headers:{
        "Content-Type": "multipart/form-data",
      }
    })

    return
  } catch (err) {
    console.log("error:",err);  
  }
}

export const _delete = async (params) => {
  try {
    console.log(params);
    
    const res = await instance.delete(`ads/ad/delete/${params}`,{
      headers:{
        "Content-Type": "application/json",
      }
    })
  } catch (err) {
    console.log("error:",err); 
  }
}

export const _addNew = async (params) => {
  try {
    const res = await instance.post(`ads/ad`,params,{
      headers:{
        "Content-Type": "application/json",
      }
    })
  } catch (err) {
    console.log("error:",err); 
  }
}